package com;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.IUserDao;
import com.dao.UserDaoImp;
import com.vo.Users;

public class User_add extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;utf-8");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		
		//用户名
		String name = request.getParameter("name");
		//密码
		String pwd = request.getParameter("passWord");
		//性别
		String sex = request.getParameter("sex");
		System.out.println(sex);
		//生日年
		String year = request.getParameter("birthyear");
		//出生月
		String month = request.getParameter("birthmonth");
		//出生日
		String day = request.getParameter("birthday");
		String bir = year+"-"+month+"-"+day;
		//手机号码
		String mobile = request.getParameter("mobile");
		//收货地址
		String address = request.getParameter("address");
		IUserDao dao = new UserDaoImp();
		
		Users users = new Users();
		users.setEu_user_name(name);
		users.setEu_password(pwd);
		users.setEu_sex(sex);
		users.setEu_birthday(bir);
		users.setEu_mobile(mobile);
		users.setEu_address(address);
		try {
			 int a = dao.userAdd(users);
			 System.out.println(a);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		request.getRequestDispatcher("manage/manage-result.jsp").forward(request, response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
